<?php 
/**
 * [CT 时间转换]
 * @Author   Xuebingsi
 * @DateTime 2017-03-08T08:56:40+0800
 * @param    [int]                   $time [时间戳]
 */
function CT($time)
{
	$diff = time()-$time;
	if($diff<60){
		return "刚刚";
	}elseif($diff<3600){
		return round($diff/60)."分钟之前";
	}elseif($diff<86400){
		return round($diff/60/60)."小时之前";
	}elseif($diff<(86400*7)){
		return round($diff/86400)."天之前";
	}else{
		return date('Y-m-d',$time);
	}
}

function CTS($time)
{
	$diff = time()-$time;
	if($diff<60){
		return "刚刚";
	}elseif($diff<3600){
		return round($diff/60)."分钟之前";
	}elseif($diff<86400){
		return round($diff/60/60)."小时之前";
	}elseif($diff<(86400*7)){
		return round($diff/86400)."天之前";
	}else{
		return date('Y-m-d H:i:s',$time);
	}
}

function bbsemail($email,$title,$content)
{
	// require 'PHPMailerAutoload.php';
	Vendor('PHPMailer.PHPMailerAutoload');
	$mail = new PHPMailer;


	//$mail->SMTPDebug = 3;                               // Enable verbose debug output

	$mail->isSMTP();                                      // Set mailer to use SMTP
	$mail->Host = 'smtp.qq.com';  // Specify main and backup SMTP servers
	$mail->SMTPAuth = true;                               // Enable SMTP authentication
	$mail->Username = '1559339939@qq.com';                 // SMTP username
	$mail->Password = 'qkgiqupikjbugjgf';                           // SMTP password
	$mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
	$mail->Port = 465;                                    // TCP port to connect to

	$mail->setFrom('1559339939@qq.com', '一优大师');
	$mail->addAddress($email, '接收人');     // Add a recipient
	// $mail->addAddress('ellen@example.com');               // Name is optional
	// $mail->addReplyTo('info@example.com', 'Information');
	// $mail->addCC('cc@example.com');
	// $mail->addBCC('bcc@example.com');

	// $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
	// $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
	$mail->isHTML(true);                                  // Set email format to HTML

	$mail->Subject = $title;
	$mail->Body    = $content;
	// $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

	if(!$mail->send()) {
		//邮件发送失败  返回1
	    return 1;
	}else{
		//邮件发送成功  返回0
		return 0;
	}
}


function bbslogin()
{
    Vendor('QQConnect.API.qqConnectAPI');

    $qc = new \QC();

    $qc->qq_login();
}

function getOpenid()
{
    Vendor('QQConnect.API.qqConnectAPI');

    $qc = new \QC();

    $qc->qq_callback();

    return $qc->get_openid();
}

function getUserInfo()
{

    Vendor('QQConnect.API.qqConnectAPI');

    $qc = new \QC();

    return $qc->get_user_info();
}

 ?>
